package com.bdqn.ch11.controller;

import com.bdqn.ch11.entity.User;
import com.bdqn.ch11.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.annotation.Resource;

@Controller
public class ExampleController {

    @Resource
    UserService userService;

    @GetMapping(value = "/hello/{uname}")
    public String getUser(@PathVariable(value = "uname") String uname, Model model) {
        User user = userService.findByUserNameBiz(uname);
        model.addAttribute("user",user);
        return "demo/hello";
    }
}
